----------------------------------
--      Module Declaration      --
----------------------------------

local boss = BB["King Ymiron"]
local mod = BigWigs:New(boss, tonumber(("$Revision: 543 $"):sub(12, -3)))
if not mod then return end
mod.partyContent = true
mod.otherMenu = "Howling Fjord"
mod.zonename = BZ["Utgarde Pinnacle"]
mod.enabletrigger = boss 
mod.guid = 26861
mod.toggleoptions = {"bane", "baneBar", -1, "rot", "rotBar", "bosskill"}


--------------------------------
--        Localization        --
--------------------------------

local L = AceLibrary("AceLocale-2.2"):new("BigWigs"..boss)

L:RegisterTranslations("enUS", function() return {
	bane = "Bane",
	baneBar = "Bane Bar",
	baneBar_desc = "Display a bar for the duration of the Bane buff.",
	bane_desc = "Warn for the casting of Bane and when Bane ends.",
	bane_ended = "Bane Fades",
	bane_message = "Casting Bane",
	cmd = "Ymiron",
	rot = "Fetid Rot",
	rotBar = "Fetid Rot Bar",
	rotBar_desc = "Show a bar for the duration of Fetid Rot.",
	rot_desc = "Warn when some recieves the Fetid Rot debuff.",
	rot_message = "%s: %s",
}

end )

L:RegisterTranslations("deDE", function() return {
	bane = "Dunkle Macht",
	baneBar = "Dunkle Macht-Anzeige",
	baneBar_desc = "Eine Leiste für die Dauer von Dunkle Macht anzeigen.",
	bane_desc = "Warnung wenn Dunkle Macht gezaubert wird und wieder endet.",
	bane_ended = "Dunkle Macht läuft aus",
	bane_message = "Zaubert Dunkle Macht",
	cmd = "Ymiron",
	rot = "Eitriges Verrotten",
	rotBar = "Eitriges Verrotten-Anzeige",
	rotBar_desc = "Eine Leiste für die Dauer von Eitrigem Verrotten anzeigen.",
	rot_desc = "Warnung wenn jemand von Eitriges Verrotten betroffen ist.",
	rot_message = "%s: %s",
}

end )

L:RegisterTranslations("esES", function() return {
}

end )

L:RegisterTranslations("esMX", function() return {
}

end )

L:RegisterTranslations("frFR", function() return {
	bane = "Plaie",
	baneBar = "Plaie - Barre",
	baneBar_desc = "Affiche une barre indiquant la durée de la Plaie.",
	bane_desc = "Prévient quand Ymiron incante Plaie.",
	bane_ended = "Plaie terminée",
	bane_message = "Plaie en incantation",
	cmd = "Ymiron",
	rot = "Pourriture fétide",
	rotBar = "Pourriture fétide - Barre",
	rotBar_desc = "Affiche une barre indiquant la durée de la Pourriture fétide.",
	rot_desc = "Prévient quand un joueur subit les effets de la Pourriture fétide.",
	rot_message = "%s : %s",
}

end )

L:RegisterTranslations("koKR", function() return {
	bane = "파멸",
	baneBar = "파멸 바",
	baneBar_desc = "파멸 버프가 지속되는 바를 표시합니다.",
	bane_desc = "파멸 시전과 종료를 알립니다.",
	bane_ended = "파멸 사라짐",
	bane_message = "파멸 시전",
	cmd = "이미론",
	rot = "악취나는 부패",
	rotBar = "악취나는 부패 바",
	rotBar_desc = "악취나는 부패가 지속되는 바를 표시합니다.",
	rot_desc = "악취나는 부패 디버프에 걸린 플레이어를 알립니다.",
	rot_message = "%s: %s",
}

end )

L:RegisterTranslations("ruRU", function() return {
	bane = "Погибель",
	baneBar = "Полоса Погибели",
	baneBar_desc = "Отображать полосу продолжительности баффа Погибели.",
	bane_desc = "Предупреждать о применении Погибели.",
	bane_ended = "Погибель рассеялась",
	bane_message = "Применение Погибели",
	cmd = "Имирон",
	rot = "Смрадная гниль",
	rotBar = "Полоса Смрадной гнили",
	rotBar_desc = "Отображать полосу продолжительности Смрадной гнили.",
	rot_desc = "Предупреждать, когда кто-либо получает дебафф Смрадной гнили.",
	rot_message = "%s: %s",
}

end )

L:RegisterTranslations("zhCN", function() return {
	bane = "灾祸",
	baneBar = "灾祸计时条",
	baneBar_desc = "当灾祸持续时显示计时条。",
	bane_desc = "当正在施放灾祸或灾祸消失时发出警报。",
	bane_ended = "灾祸 消失！",
	bane_message = "正在施放 灾祸！",
	rot = "恶臭溃烂",
	rotBar = "恶臭溃烂计时条",
	rotBar_desc = "当恶臭溃烂持续时显示计时条。",
	rot_desc = "当玩家中了恶臭溃烂减益时发出警报。",
	rot_message = "%s：%s！",
}

end )

L:RegisterTranslations("zhTW", function() return {
	bane = "災禍",
	baneBar = "災禍計時條",
	baneBar_desc = "當災禍持續時顯示計時條。",
	bane_desc = "當正在施放災禍或災禍消失時發出警報。",
	bane_ended = "災禍 消失！",
	bane_message = "正在施放 災禍！",
	cmd = "依米倫",
	rot = "惡臭腐氣",
	rotBar = "惡臭腐氣計時條",
	rotBar_desc = "當惡臭腐氣持續時顯示計時條。",
	rot_desc = "當玩家中了惡臭腐氣減益時發出警報。",
	rot_message = "%s：%s！",
}

end )

----------------------------------
--        Initialization        --
----------------------------------

function mod:OnEnable()
	self:AddCombatListener("SPELL_CAST_START", "Bane", 48294, 59301)
	self:AddCombatListener("SPELL_AURA_APPLIED", "BaneAura", 48294, 59301)
	self:AddCombatListener("SPELL_AURA_REMOVED", "BaneAuraRemoved", 48294, 59301)
	self:AddCombatListener("SPELL_AURA_APPLIED", "Rot", 48291, 59300)
	self:AddCombatListener("SPELL_AURA_REMOVED", "RotRemoved", 48291, 59300)
	self:AddCombatListener("UNIT_DIED", "BossDeath")
end

----------------------------------
--        Event Handlers        --
----------------------------------

function mod:Bane(_, spellId, _, _, spellName)
	if self.db.profile.bane then
		self:IfMessage(L["bane_message"], "Urgent", spellId)
	end
end

function mod:BaneAura(player, spellId, _, _, spellName)
	if player ~= boss then return end
	if self.db.profile.baneBar then
		self:Bar(spellName, 5, spellId)
	end
end

function mod:BaneAuraRemoved(player, spellId, _, _, spellName)
	if player ~= boss then return end
	if self.db.profile.bane then
		self:IfMessage(L["bane_ended"], "Positive", spellId)
	end
	if self.db.profile.baneBar then
		self:TriggerEvent("BigWigs_StopBar", self, spellName)
	end
end

function mod:Rot(player, spellId, _, _, spellName)
	if self.db.profile.rot then
		self:IfMessage(L["rot_message"]:format(spellName, player), "Urgent", spellId)
	end
	if self.db.profile.rotBar then
		self:Bar(L["rot_message"]:format(spellName, player), 9, spellId)
	end
end

function mod:RotRemoved(player, _, _, _, spellName)
	if self.db.profile.rotBar then
		self:TriggerEvent("BigWigs_StopBar", self, L["rot_message"]:format(spellName, player))
	end
end
